﻿using System;
using System.Windows;
using Microsoft.Phone.Controls;

namespace STEM123
{
    /// <summary>
    /// Main search page of application.
    /// </summary>
    public partial class MainSearchPage : PhoneApplicationPage
    {
        #region Private members

        /// <summary>
        /// Occurs when user clicks on search button.
        /// </summary>
        /// <param name="sender">Button reference.</param>
        /// <param name="e">Event specific arguments.</param>
        private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(this.txtBoxSearchTerm.Text.Trim()))
            {
                MessageBox.Show("Please type what you are searching for.");
                this.txtBoxSearchTerm.Focus();
            }
            else
            {
                SearchViewModel.Instance.Term = this.txtBoxSearchTerm.Text.Trim();
                NavigationService.Navigate(new Uri("/ResultsPage.xaml", UriKind.Relative));
            }
        }

        /// <summary>
        /// Occurs when user clicks on explain button.
        /// </summary>
        /// <param name="sender">Button reference.</param>
        /// <param name="e">Event specific arguments.</param>
        private void btnExplain_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/CreateTerm.xaml", UriKind.Relative));
        }

        #endregion

        #region Public members

        /// <summary>
        /// Initializes a new instance of MainSearchPage.
        /// </summary>
        public MainSearchPage()
        {
            InitializeComponent();
        }

        #endregion
    }
}